<template>
  <div class="widget-wrap widget-panel">
    <h3 class="widget-title">分类</h3>
    <div class="widget">
      <ul class="category-list">
        <li v-for="item in categoryList" class="category-list-item" :key="item.id">
          <a class="category-list-link" style=" cursor: pointer"
             @click="routeCategory(item.id,item.categoryname)">{{item.categoryname}}</a><span
          class="category-list-count">{{item.articleCount}}</span>
        </li>

      </ul>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'categoryList',
    props: {
      categoryList: Array
    },
    watch: {
      '$route' (to, from) {
        this.$router.go(0);
      }
    },
    methods: {
      routeCategory(id, categoryName) {
        const that = this;
        that.$router.push({
          path: "/categories", query: {
            id: id,
            categoryName: categoryName
          }
        });
      }
    }

  }
</script>

<style>

</style>
